package com.xing.binbackend.pattern.adapter24.operation;

import java.util.Map;

// 3. 适配器实现（Adapters）
public class AwsMonitorAdapter implements CloudMonitor {
    private final AwsCloudSDK awsSDK = new AwsCloudSDK();

    @Override
    public MetricData getCpuUsage(String instanceId) {
        Map<String, Object> data = awsSDK.getMetricStatistics(
                "AWS/EC2", "CPUUtilization", instanceId);
        return new MetricData((double)data.get("value"), (long)data.get("timestamp"));
    }

    @Override
    public MetricData getMemoryUsage(String instanceId) {
        return null;
    }

    @Override
    public void setAlert(String metricName, double threshold) {
        awsSDK.putMetricAlarm(metricName + "_Alarm", metricName, threshold);
    }

    @Override
    public String getVendorType() {
        return getClass().getSimpleName();
    }
    // 其他方法类似...
}
